package cn.iocoder.yudao.module.mybusiness.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mybusiness.domain.BussinessMod;
import cn.iocoder.yudao.module.mybusiness.domain.Facility;
import cn.iocoder.yudao.module.mybusiness.param.FacilityParam;
import cn.iocoder.yudao.module.mybusiness.param.ModParam;
import cn.iocoder.yudao.module.mybusiness.service.ModService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.security.PermitAll;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController
@RequestMapping("/mod")
public class ModController {

    @Autowired
    private ModService modService;

    @GetMapping("/getList")
    @Operation(summary = "获取零件规格列表")
    @PermitAll
    public CommonResult<PageResult<BussinessMod>> getList(ModParam modParam){
        PageResult<BussinessMod> pageResult = modService.getList(modParam);
        return success(pageResult);
    }

    @PutMapping("/create")
    @Operation(summary = "新增零件规格")
    @PermitAll
    public CommonResult<Boolean> create(@RequestBody BussinessMod mod){
        modService.create(mod);
        return success(true);
    }

    @PutMapping("/update")
    @Operation(summary = "修改零件规格")
    @PermitAll
    public CommonResult<Boolean> update(@RequestBody BussinessMod mod){
        modService.updateById(mod);
        return success(true);
    }

    @GetMapping("/delete")
    @Operation(summary = "删除零件规格")
    @PermitAll
    public CommonResult<Boolean> delete(@RequestParam("id")Long id){
        modService.delete(id);
        return success(true);
    }

}
